package com.marry.webservice.cilent;

import org.apache.cxf.endpoint.Client;
import org.apache.cxf.jaxws.endpoint.dynamic.JaxWsDynamicClientFactory;
import org.springframework.util.ObjectUtils;

import javax.crypto.Cipher;

/**
 * @author ml
 * @create 2017-09-20--16:43
 */
public class WSClient {

    public static void main(String[] args) {

        JaxWsDynamicClientFactory dcf=JaxWsDynamicClientFactory.newInstance();
        Client client=dcf.createClient("http://127.0.0.1:8080/webservices/layout?wsdl");
        client.getOutInterceptors().add(new ClientLoginInterceptor("admin","pass"));
        Object[] objects=new Object[0];

        try {
            objects=client.invoke("sayHi","   malin");
        } catch (Exception e) {
            e.printStackTrace();
        }

        if(!ObjectUtils.isEmpty(objects)){
            System.out.println(objects[0].getClass());
            System.out.println(objects[0].toString());

        }
    }
}
